-- local skynet = require "skynet"
-- local httpc = require "http.httpc"
-- local dns = require "skynet.dns"

-- local function main()
--     httpc.dns() -- set dns server
--     httpc.timeout = 100 -- set timeout 1 second
--     print("GET baidu.com")
--     local respheader = {}
--     local status, body = httpc.request("GET", "baidu.com", "/", respheader, { host = "baidu.com" })
--     --local status, body = httpc.get("baidu.com", "/", respheader, { host = "baidu.com" })
--     print("[header] =====>")
--     for k,v in pairs(respheader) do
--         print(k,v)
--     end
--     print("[body] =====>", status)
--     print(body)
-- end

-- skynet.start(function()
--     print(pcall(main))
--     skynet.exit()
-- end)

local skynet = require "skynet"
local httpc = require "http.httpc"
local dns = require "skynet.dns"

local function main()
    httpc.dns() -- set dns server
    httpc.timeout = 100 -- set timeout 1 second
    print("GET 127.0.0.1:8001")
    local respheader = {}
    local status, body = httpc.request("GET", "127.0.0.1:8222", "/?color=blue&text=abc", respheader)
    print("[header] =====>")
    for k,v in pairs(respheader) do
        print(k,v)
    end
    print("[body] =====>", status)
    print(body)
end

skynet.start(function()
    print(pcall(main))
    skynet.exit()
end)
